<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="MySQL内置函数, 夏天">
    <meta name="description" content="爱一直在线">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>MySQL内置函数 | 夏天</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
    <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }

    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }

   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}


    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script><meta name="generator" content="Hexo 4.2.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"><style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }

    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }

   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}


    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script></head>



 <div id="loading-container">
     <p class="loading-text">玩命加载中 . . . </p> 
     <div class="loading-image">
         <div></div>
         <div></div>
         <div></div>
         <div></div> 
         <div></div>
     </div>
 </div><body>    
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">夏天</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>主页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <span>百宝箱</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/webstack/cn/index.html">
          
          <i class="fas fa-briefcase" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>宝箱一</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/nav/">
          
          <i class="fas fa-briefcase" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>宝箱二</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-sitemap" style="zoom: 0.6;"></i>
      
      <span>统计</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/tags">
          
          <i class="fas fa-tags" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>标签</span>
        </a>
      </li>
      
      <li>
        <a href="/categories">
          
          <i class="fas fa-bookmark" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>分类</span>
        </a>
      </li>
      
      <li>
        <a href="/archives">
          
          <i class="fas fa-archive" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>归档</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fa fa-gamepad" style="zoom: 0.6;"></i>
      
      <span>游戏</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/magiccube/">
          
          <i class="fa fa-money" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>魔方</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/game-2048">
          
          <i class="fa fa-money" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>2048</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-list" style="zoom: 0.6;"></i>
      
      <span>知识库</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/java/">
          
          <i class="fas fa-music" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>JAVA</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/mysql/">
          
          <i class="fas fa-film" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>MySQL</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/nosql/">
          
          <i class="fas fa-book" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>NoSQL</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/oracle/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>oracle</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/structure">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>算法</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/hadoop/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>大数据</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/docker">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>K8S</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/frontend/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>前端</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <span>联系</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/contact">
          
          <i class="fas fa-comments" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>联系</span>
        </a>
      </li>
      
      <li>
        <a href="/about">
          
          <i class="fas fa-user-circle" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>关于</span>
        </a>
      </li>
      
      <li>
        <a href="/friends">
          
          <i class="fas fa-address-book" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>友链</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="https://news.qq.com/zt2020/page/feiyan.htm#/?nojump=1" target="_blank" rel="noopener" class="waves-effect waves-light">
      
      <i class="fas fa-heartbeat" style="zoom: 0.6;"></i>
      
      <span>疫情</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">夏天</div>
        <div class="logo-desc">
            
            爱一直在线
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			主页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fas fa-fw fa-link"></i>
			
			百宝箱
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/webstack/cn/index.html " style="margin-left:50px";>
				  
				   <i class="fa fas fa-briefcase" style="position: absolute;left:28px" ></i>
			      
		          <span>宝箱一</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/nav/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-briefcase" style="position: absolute;left:28px" ></i>
			      
		          <span>宝箱二</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-sitemap"></i>
			
			统计
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="/tags " style="margin-left:50px";>
				  
				   <i class="fa fas fa-tags" style="position: absolute;left:28px" ></i>
			      
		          <span>标签</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/categories " style="margin-left:50px";>
				  
				   <i class="fa fas fa-bookmark" style="position: absolute;left:28px" ></i>
			      
		          <span>分类</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/archives " style="margin-left:50px";>
				  
				   <i class="fa fas fa-archive" style="position: absolute;left:28px" ></i>
			      
		          <span>归档</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fa fa-gamepad"></i>
			
			游戏
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/magiccube/ " style="margin-left:50px";>
				  
				   <i class="fa fa fa-money" style="position: absolute;left:28px" ></i>
			      
		          <span>魔方</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/game-2048 " style="margin-left:50px";>
				  
				   <i class="fa fa fa-money" style="position: absolute;left:28px" ></i>
			      
		          <span>2048</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-list"></i>
			
			知识库
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/java/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-music" style="position: absolute;left:28px" ></i>
			      
		          <span>JAVA</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/mysql/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-film" style="position: absolute;left:28px" ></i>
			      
		          <span>MySQL</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/nosql/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-book" style="position: absolute;left:28px" ></i>
			      
		          <span>NoSQL</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/oracle/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>oracle</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/structure " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>算法</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/hadoop/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>大数据</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/docker " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>K8S</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/frontend/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>前端</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fas fa-fw fa-link"></i>
			
			联系
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="/contact " style="margin-left:50px";>
				  
				   <i class="fa fas fa-comments" style="position: absolute;left:28px" ></i>
			      
		          <span>联系</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/about " style="margin-left:50px";>
				  
				   <i class="fa fas fa-user-circle" style="position: absolute;left:28px" ></i>
			      
		          <span>关于</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/friends " style="margin-left:50px";>
				  
				   <i class="fa fas fa-address-book" style="position: absolute;left:28px" ></i>
			      
		          <span>友链</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="https://news.qq.com/zt2020/page/feiyan.htm#/?nojump=1" target="_blank" rel="noopener" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-heartbeat"></i>
			
			疫情
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://caimengzhi.gitee.io/books/" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://caimengzhi.gitee.io/books/" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '1f1c5b2fad778434024f1537986346927917f4755a6e7d3fd91f22653b7c3132';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('您好，BOSS,请输入密码')).toString(CryptoJS.enc.Hex)) {
                alert('哈哈密码错了！！！');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/2.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">MySQL内置函数</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">学习</span>
                            </a>
                        
                            <a href="/tags/SQL/">
                                <span class="chip bg-color">SQL</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/MySQL/" class="post-category">
                                MySQL
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-03-21
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2020-03-24
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    3k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    13 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>

        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <center><h1>MySQL内置函数</h1></center>

<h2 id="1-MySQL-数值型函数"><a href="#1-MySQL-数值型函数" class="headerlink" title="1. MySQL 数值型函数"></a>1. MySQL 数值型函数</h2><table>
<thead>
<tr>
<th>函数名称</th>
<th>作 用</th>
</tr>
</thead>
<tbody><tr>
<td>ABS</td>
<td>求绝对值</td>
</tr>
<tr>
<td>SQRT</td>
<td>求二次方根</td>
</tr>
<tr>
<td>MOD</td>
<td>求余数</td>
</tr>
<tr>
<td>CEIL 和 CEILING</td>
<td>两个函数功能相同，都是返回不小于参数的最小整数，即向上取整</td>
</tr>
<tr>
<td>FLOOR</td>
<td>向下取整，返回值转化为一个BIGINT</td>
</tr>
<tr>
<td>RAND</td>
<td>生成一个0~1之间的随机数，传入整数参数是，用来产生重复序列</td>
</tr>
<tr>
<td>ROUND</td>
<td>对所传参数进行四舍五入</td>
</tr>
<tr>
<td>SIGN</td>
<td>返回参数的符号</td>
</tr>
<tr>
<td>POW 和 POWER</td>
<td>两个函数的功能相同，都是所传参数的次方的结果值</td>
</tr>
<tr>
<td>SIN</td>
<td>求正弦值</td>
</tr>
<tr>
<td>ASIN</td>
<td>求反正弦值，与函数 SIN 互为反函数</td>
</tr>
<tr>
<td>COS</td>
<td>求余弦值</td>
</tr>
<tr>
<td>ACOS</td>
<td>求反余弦值，与函数 COS 互为反函数</td>
</tr>
<tr>
<td>TAN</td>
<td>求正切值</td>
</tr>
<tr>
<td>ATAN</td>
<td>求反正切值，与函数 TAN 互为反函数</td>
</tr>
<tr>
<td>COT</td>
<td>求余切值</td>
</tr>
</tbody></table>
<h3 id="1-1-abs"><a href="#1-1-abs" class="headerlink" title="1.1 abs"></a>1.1 abs</h3><p>绝对值函数 ABS(x) 返回 x 的绝对值。正数的绝对值是其本身，负数的绝对值为其相反数，0 的绝对值是 0。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token operator">-</span><span class="token number">123</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------+</span>
<span class="token operator">|</span> <span class="token operator">-</span><span class="token number">123</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------+</span>
<span class="token operator">|</span> <span class="token operator">-</span><span class="token number">123</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> abs<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">123</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+</span>
<span class="token operator">|</span> abs<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">123</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+</span>
<span class="token operator">|</span>       <span class="token number">123</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.01</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-2-sqrt"><a href="#1-2-sqrt" class="headerlink" title="1.2 sqrt"></a>1.2 sqrt</h3><p>平方根函数 SQRT(x) 返回非负数 x 的二次方根。负数没有平方根，返回结果为 NULL。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> sqrt<span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">,</span>sqrt<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+</span>
<span class="token operator">|</span> sqrt<span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span> <span class="token operator">|</span> sqrt<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">16</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+</span>
<span class="token operator">|</span>        <span class="token number">4</span> <span class="token operator">|</span>      <span class="token boolean">NULL</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-3-mod"><a href="#1-3-mod" class="headerlink" title="1.3 mod"></a>1.3 mod</h3><p>求余函数 MOD(x,y) 返回 x 被 y 除后的余数，MOD() 对于带有小数部分的数值也起作用，它返回除法运算后的余数。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> mod<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>mod<span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+</span>
<span class="token operator">|</span> mod<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">|</span> mod<span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+</span>
<span class="token operator">|</span>         <span class="token number">1</span> <span class="token operator">|</span>         <span class="token number">1</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-4-ceil-ceiling"><a href="#1-4-ceil-ceiling" class="headerlink" title="1.4 ceil/ceiling"></a>1.4 ceil/ceiling</h3><p>取整函数 CEIL(x) 和 CEILING(x) 的意义相同，返回不小于 x 的最小整数值，返回值转化为一个 BIGINT。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> ceil<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceil<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceil<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceil<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceiling<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceiling<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceiling<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>ceiling<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+------------+------------+--------------+--------------+---------------+---------------+</span>
<span class="token operator">|</span> ceil<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceil<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceil<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceil<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceiling<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceiling<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceiling<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> ceiling<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+------------+------------+--------------+--------------+---------------+---------------+</span>
<span class="token operator">|</span>         <span class="token number">2</span> <span class="token operator">|</span>         <span class="token number">2</span> <span class="token operator">|</span>         <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>         <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>            <span class="token number">2</span> <span class="token operator">|</span>            <span class="token number">2</span> <span class="token operator">|</span>            <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>            <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------+-----------+------------+------------+--------------+--------------+---------------+---------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-5-floor"><a href="#1-5-floor" class="headerlink" title="1.5 floor"></a>1.5 floor</h3><p>回小于 x 的最大整数值</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> floor<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>floor<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>floor<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>floor<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+------------+-------------+-------------+</span>
<span class="token operator">|</span> floor<span class="token punctuation">(</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span> floor<span class="token punctuation">(</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> floor<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> floor<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.6</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+------------+-------------+-------------+</span>
<span class="token operator">|</span>          <span class="token number">1</span> <span class="token operator">|</span>          <span class="token number">1</span> <span class="token operator">|</span>          <span class="token operator">-</span><span class="token number">2</span> <span class="token operator">|</span>          <span class="token operator">-</span><span class="token number">2</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+------------+-------------+-------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-6-rand"><a href="#1-6-rand" class="headerlink" title="1.6 rand"></a>1.6 rand</h3><p>生成一个0~1之间的随机数，传入整数参数是，用来产生重复序列</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> rand<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>rand<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+</span>
<span class="token operator">|</span> rand<span class="token punctuation">(</span><span class="token punctuation">)</span>              <span class="token operator">|</span> rand<span class="token punctuation">(</span><span class="token punctuation">)</span>             <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+</span>
<span class="token operator">|</span> <span class="token number">0.15254052090695178</span> <span class="token operator">|</span> <span class="token number">0.7564555609193216</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-7-round"><a href="#1-7-round" class="headerlink" title="1.7 round"></a>1.7 round</h3><p>返回最接近于参数 x 的整数；ROUND(x,y) 函数对参数x进行四舍五入的操作，返回值保留小数点后面指定的y位</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">round</span><span class="token punctuation">(</span><span class="token number">1.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.1234</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.1257</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------+------------+------------------+------------------+</span>
<span class="token operator">|</span> <span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token function">round</span><span class="token punctuation">(</span><span class="token number">1.5</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.1234</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token function">round</span><span class="token punctuation">(</span><span class="token number">10.1257</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------+------------+------------------+------------------+</span>
<span class="token operator">|</span>          <span class="token number">10</span> <span class="token operator">|</span>          <span class="token number">2</span> <span class="token operator">|</span>           <span class="token number">10.123</span> <span class="token operator">|</span>           <span class="token number">10.126</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------+------------+------------------+------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-8-sign"><a href="#1-8-sign" class="headerlink" title="1.8 sign"></a>1.8 sign</h3><p>符号函数 sign(x) 返回参数的符号，x 的值为负、零和正时返回结果依次为 -1、0 和 1。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> sign<span class="token punctuation">(</span><span class="token number">10.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>sign<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">10.3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>sign<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+---------+</span>
<span class="token operator">|</span> sign<span class="token punctuation">(</span><span class="token number">10.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> sign<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">10.3</span><span class="token punctuation">)</span> <span class="token operator">|</span> sign<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+---------+</span>
<span class="token operator">|</span>          <span class="token number">1</span> <span class="token operator">|</span>          <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>       <span class="token number">0</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+---------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-9-pow-x-y-power-x-y"><a href="#1-9-pow-x-y-power-x-y" class="headerlink" title="1.9 pow(x,y)/power(x,y)"></a>1.9 pow(x,y)/power(x,y)</h3><p>POW(x,y) 函数和 POWER(x,y) 函数用于计算 x 的 y 次方</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> pow<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>pow<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>pow<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>pow<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+-----------+------------+</span>
<span class="token operator">|</span> pow<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> pow<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> pow<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span> pow<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+-----------+------------+</span>
<span class="token operator">|</span>       <span class="token number">16</span> <span class="token operator">|</span>    <span class="token number">0.0625</span> <span class="token operator">|</span>         <span class="token number">4</span> <span class="token operator">|</span>       <span class="token number">0.25</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-----------+-----------+------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> power<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>power<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>power<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>power<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+-------------+--------------+</span>
<span class="token operator">|</span> power<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> power<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> power<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span> power<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+-------------+--------------+</span>
<span class="token operator">|</span>         <span class="token number">16</span> <span class="token operator">|</span>      <span class="token number">0.0625</span> <span class="token operator">|</span>           <span class="token number">4</span> <span class="token operator">|</span>         <span class="token number">0.25</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+-------------+-------------+--------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-10-sin"><a href="#1-10-sin" class="headerlink" title="1.10 sin"></a>1.10 sin</h3><p>正弦函数 SIN(x) 返回 x 的正弦值，其中 x 为弧度值</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> sin<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>sin<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">/</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>sin<span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------+--------------------+------------------------+</span>
<span class="token operator">|</span> sin<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">|</span> sin<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">/</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>    <span class="token operator">|</span> sin<span class="token punctuation">(</span><span class="token number">1</span><span class="token operator">*</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>            <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------+--------------------+------------------------+</span>
<span class="token operator">|</span>             <span class="token number">1</span> <span class="token operator">|</span> <span class="token number">0.4999999981862006</span> <span class="token operator">|</span> <span class="token number">1.2246467991473532e</span><span class="token operator">-</span><span class="token number">16</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------+--------------------+------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-11-asin"><a href="#1-11-asin" class="headerlink" title="1.11 asin"></a>1.11 asin</h3><p>反正弦函数 ASIN(x) 返回 x 的反正弦值，若 x 不在 -1 到 1 的范围之内，则返回 NULL。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> asin<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>asin<span class="token punctuation">(</span><span class="token number">0.6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>asin<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------+--------------------+------------+</span>
<span class="token operator">|</span> asin<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span>            <span class="token operator">|</span> asin<span class="token punctuation">(</span><span class="token number">0.6</span><span class="token punctuation">)</span>          <span class="token operator">|</span> asin<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.2</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------+--------------------+------------+</span>
<span class="token operator">|</span> <span class="token number">1.5707963267948966</span> <span class="token operator">|</span> <span class="token number">0.6435011087932844</span> <span class="token operator">|</span>       <span class="token boolean">NULL</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------+--------------------+------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-12-cos"><a href="#1-12-cos" class="headerlink" title="1.12 cos"></a>1.12 cos</h3><p>余弦函数 COS(x) 返回 x 的余弦值，x 为弧度值</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> cos<span class="token punctuation">(</span><span class="token operator">-</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cos<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cos<span class="token punctuation">(</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+--------+--------------------+-----------+</span>
<span class="token operator">|</span> cos<span class="token punctuation">(</span><span class="token operator">-</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">|</span> cos<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">|</span> cos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>            <span class="token operator">|</span> cos<span class="token punctuation">(</span>pi<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+--------+--------------------+-----------+</span>
<span class="token operator">|</span>         <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>      <span class="token number">1</span> <span class="token operator">|</span> <span class="token number">0.5403023058681398</span> <span class="token operator">|</span>        <span class="token operator">-</span><span class="token number">1</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">------------+--------+--------------------+-----------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-13-acos"><a href="#1-13-acos" class="headerlink" title="1.13 acos"></a>1.13 acos</h3><p>反余弦函数 ACOS(x) 。x 值的范围必须在 -1 和 1 之间，否则返回 NULL。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span>  acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token number">0.8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>acos<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-------------------+-------------------+--------------------+--------------------+---------+---------+</span>
<span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>          <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.8</span><span class="token punctuation">)</span>        <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span>            <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token number">0.8</span><span class="token punctuation">)</span>          <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">|</span> acos<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-------------------+-------------------+--------------------+--------------------+---------+---------+</span>
<span class="token operator">|</span>     <span class="token boolean">NULL</span> <span class="token operator">|</span> <span class="token number">3.141592653589793</span> <span class="token operator">|</span> <span class="token number">2.498091544796509</span> <span class="token operator">|</span> <span class="token number">1.5707963267948966</span> <span class="token operator">|</span> <span class="token number">0.6435011087932843</span> <span class="token operator">|</span>       <span class="token number">0</span> <span class="token operator">|</span>    <span class="token boolean">NULL</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------+-------------------+-------------------+--------------------+--------------------+---------+---------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-14-tan"><a href="#1-14-tan" class="headerlink" title="1.14 tan"></a>1.14 tan</h3><p>正切函数 TAN(x) 返回 x 的正切值，x 为给定的弧度值。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span>  tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token number">0.8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>tan<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------+---------------------+---------------------+--------+--------------------+--------------------+--------------------+</span>
<span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span>           <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>             <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span>           <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token number">0.8</span><span class="token punctuation">)</span>           <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span>             <span class="token operator">|</span> tan<span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span>             <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------+---------------------+---------------------+--------+--------------------+--------------------+--------------------+</span>
<span class="token operator">|</span> <span class="token number">2.185039863261519</span> <span class="token operator">|</span> <span class="token operator">-</span><span class="token number">1.5574077246549023</span> <span class="token operator">|</span> <span class="token operator">-</span><span class="token number">0.5463024898437905</span> <span class="token operator">|</span>      <span class="token number">0</span> <span class="token operator">|</span> <span class="token number">1.0296385570503641</span> <span class="token operator">|</span> <span class="token number">1.5574077246549023</span> <span class="token operator">|</span> <span class="token operator">-</span><span class="token number">2.185039863261519</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------+---------------------+---------------------+--------+--------------------+--------------------+--------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-15-atan"><a href="#1-15-atan" class="headerlink" title="1.15 atan"></a>1.15 atan</h3><p>正切 ATAN(x) 返回 x 的反正切值，正切为 x 的值。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span>  atan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>atan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>atan<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>atan<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>atan<span class="token punctuation">(</span><span class="token number">1.5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+---------------------+---------+--------------------+-------------------+</span>
<span class="token operator">|</span> atan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span>          <span class="token operator">|</span> atan<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>            <span class="token operator">|</span> atan<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">|</span> atan<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token punctuation">)</span>          <span class="token operator">|</span> atan<span class="token punctuation">(</span><span class="token number">1.5</span><span class="token punctuation">)</span>         <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+---------------------+---------+--------------------+-------------------+</span>
<span class="token operator">|</span> <span class="token operator">-</span><span class="token number">0.4636476090008061</span> <span class="token operator">|</span> <span class="token operator">-</span><span class="token number">0.7853981633974483</span> <span class="token operator">|</span>       <span class="token number">0</span> <span class="token operator">|</span> <span class="token number">0.4636476090008061</span> <span class="token operator">|</span> <span class="token number">0.982793723247329</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+---------------------+---------+--------------------+-------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="1-16-cot"><a href="#1-16-cot" class="headerlink" title="1.16 cot"></a>1.16 cot</h3><p>余切函数 COT(x) 返回 x 的余切值，x 是给定的弧度值。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> cot<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cot<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cot<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>cot<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+-------------------+--------------------+</span>
<span class="token operator">|</span> cot<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>             <span class="token operator">|</span> cot<span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">0.5</span><span class="token punctuation">)</span>          <span class="token operator">|</span> cot<span class="token punctuation">(</span><span class="token number">0.5</span><span class="token punctuation">)</span>          <span class="token operator">|</span> cot<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span>             <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+-------------------+--------------------+</span>
<span class="token operator">|</span> <span class="token operator">-</span><span class="token number">0.6420926159343306</span> <span class="token operator">|</span> <span class="token operator">-</span><span class="token number">1.830487721712452</span> <span class="token operator">|</span> <span class="token number">1.830487721712452</span> <span class="token operator">|</span> <span class="token number">0.6420926159343306</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+--------------------+-------------------+--------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h2 id="2-MySQL-字符串函数"><a href="#2-MySQL-字符串函数" class="headerlink" title="2. MySQL 字符串函数"></a>2. MySQL 字符串函数</h2><table>
<thead>
<tr>
<th>函数名称</th>
<th>作 用</th>
</tr>
</thead>
<tbody><tr>
<td>LENGTH</td>
<td>计算字符串长度函数，返回字符串的字节长度</td>
</tr>
<tr>
<td>CONCAT</td>
<td>合并字符串函数，返回结果为连接参数产生的字符串，参数可以使一个或多个</td>
</tr>
<tr>
<td>INSERT</td>
<td>替换字符串函数</td>
</tr>
<tr>
<td>LOWER</td>
<td>将字符串中的字母转换为小写</td>
</tr>
<tr>
<td>UPPER</td>
<td>将字符串中的字母转换为大写</td>
</tr>
<tr>
<td>LEFT</td>
<td>从左侧字截取符串，返回字符串左边的若干个字符</td>
</tr>
<tr>
<td>RIGHT</td>
<td>从右侧字截取符串，返回字符串右边的若干个字符</td>
</tr>
<tr>
<td>TRIM</td>
<td>删除字符串左右两侧的空格</td>
</tr>
<tr>
<td>REPLACE</td>
<td>字符串替换函数，返回替换后的新字符串</td>
</tr>
<tr>
<td>SUBSTRING</td>
<td>截取字符串，返回从指定位置开始的指定长度的字符换</td>
</tr>
<tr>
<td>REVERSE</td>
<td>字符串反转（逆序）函数，返回与原始字符串顺序相反的字符串</td>
</tr>
</tbody></table>
<h3 id="2-1-length"><a href="#2-1-length" class="headerlink" title="2.1 length"></a>2.1 length</h3><p> LENGTH(str) 函数的返回值为字符串的字节长度，使用 uft8（UNICODE 的一种变长字符编码，又称万国码）编码字符集时，一个汉字是 3 个字节，一个数字或字母是一个字节。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> length<span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>length<span class="token punctuation">(</span><span class="token string">'cmz'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------+---------------+</span>
<span class="token operator">|</span> length<span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">)</span> <span class="token operator">|</span> length<span class="token punctuation">(</span><span class="token string">'cmz'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------+---------------+</span>
<span class="token operator">|</span>                   <span class="token number">10</span> <span class="token operator">|</span>             <span class="token number">3</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------+---------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-2-concat"><a href="#2-2-concat" class="headerlink" title="2.2 concat"></a>2.2 concat</h3><p>CONCAT(sl，s2，…) 函数返回结果为连接参数产生的字符串，或许有一个或多个参数。若有任何一个参数为 NULL，则返回值为 NULL。若所有参数均为非二进制字符串，则结果为非二进制字符串。若自变量中含有任一二进制字符串，则结果为一个二进制字符串</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> concat<span class="token punctuation">(</span><span class="token string">'I'</span><span class="token punctuation">,</span><span class="token string">'Love'</span><span class="token punctuation">,</span><span class="token string">"China"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------------+</span>
<span class="token operator">|</span> concat<span class="token punctuation">(</span><span class="token string">'I'</span><span class="token punctuation">,</span><span class="token string">'Love'</span><span class="token punctuation">,</span><span class="token string">"China"</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------------+</span>
<span class="token operator">|</span> ILoveChina                 <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">----------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-3-insert"><a href="#2-3-insert" class="headerlink" title="2.3 insert"></a>2.3 insert</h3><p>替换字符串函数 INSERT(s1，x，len，s2) 返回字符串 s1，子字符串起始于 x 位置，并且用 len 个字符长的字符串代替 s2。若 x 超过字符串长度，则返回值为原始字符串。假如 len 的长度大于其他字符串的长度，则从位置 x 开始替换。若任何一个参数为 NULL，则返回值为 NULL。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'6'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token operator">|</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'6'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token operator">|</span> i_love_summer                       <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'4'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token operator">|</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'4'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token operator">|</span> i_love_summer                       <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-------------------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span>

mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'10'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------------------------+</span>
<span class="token operator">|</span> <span class="token keyword">insert</span><span class="token punctuation">(</span><span class="token string">'i_love_you'</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">,</span><span class="token string">'10'</span><span class="token punctuation">,</span><span class="token string">'summer'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------------------------+</span>
<span class="token operator">|</span> i_love_summer                        <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-4-lower"><a href="#2-4-lower" class="headerlink" title="2.4 lower"></a>2.4 lower</h3><p>字母小写转换函数 LOWER(str) 可以将字符串 str 中的字母字符全部转换成小写。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> lower<span class="token punctuation">(</span><span class="token string">"CAIMENGHI_12_*&amp;^"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+</span>
<span class="token operator">|</span> lower<span class="token punctuation">(</span><span class="token string">"CAIMENGHI_12_*&amp;^"</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+</span>
<span class="token operator">|</span> caimenghi_12_<span class="token operator">*</span><span class="token operator">&amp;</span><span class="token operator">^</span>          <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-5-upper"><a href="#2-5-upper" class="headerlink" title="2.5 upper"></a>2.5 upper</h3><p>字母大写转换函数 UPPER(str) 可以将字符串 str 中的字母字符全部转换成大写。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> upper<span class="token punctuation">(</span><span class="token string">"caiMengZhi"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>upper<span class="token punctuation">(</span><span class="token string">'123msnDB'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+-------------------+</span>
<span class="token operator">|</span> upper<span class="token punctuation">(</span><span class="token string">"caiMengZhi"</span><span class="token punctuation">)</span> <span class="token operator">|</span> upper<span class="token punctuation">(</span><span class="token string">'123msnDB'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+-------------------+</span>
<span class="token operator">|</span> CAIMENGZHI          <span class="token operator">|</span> 123MSNDB          <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+-------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-6-left"><a href="#2-6-left" class="headerlink" title="2.6 left"></a>2.6 left</h3><p> LEFT(s，n) 函数返回字符串 s 最左边的 n 个字符。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">left</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">left</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+----------------------+</span>
<span class="token operator">|</span> <span class="token keyword">left</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token keyword">left</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+----------------------+</span>
<span class="token operator">|</span> cai                 <span class="token operator">|</span> caimeng              <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------+----------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-7-right"><a href="#2-7-right" class="headerlink" title="2.7 right"></a>2.7 right</h3><p>RIGHT(s，n) 函数返回字符串 s 最右边的 n 个字符.</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> <span class="token keyword">right</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">right</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------------+-----------------------+</span>
<span class="token operator">|</span> <span class="token keyword">right</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">|</span> <span class="token keyword">right</span><span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token number">7</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------------+-----------------------+</span>
<span class="token operator">|</span> zhi                   <span class="token operator">|</span> mengzhi               <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------------+-----------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-8-trim"><a href="#2-8-trim" class="headerlink" title="2.8 trim"></a>2.8 trim</h3><p>删除空格函数 TRIM(s) 删除字符串 s 两侧的空格。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> trim<span class="token punctuation">(</span><span class="token string">" cai"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>trim<span class="token punctuation">(</span><span class="token string">"zhi "</span><span class="token punctuation">)</span><span class="token punctuation">,</span>trim<span class="token punctuation">(</span><span class="token string">" caimengzhi "</span><span class="token punctuation">)</span><span class="token punctuation">,</span>trim<span class="token punctuation">(</span><span class="token string">"cai mengzhi"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------+--------------+----------------------+---------------------+</span>
<span class="token operator">|</span> trim<span class="token punctuation">(</span><span class="token string">" cai"</span><span class="token punctuation">)</span> <span class="token operator">|</span> trim<span class="token punctuation">(</span><span class="token string">"zhi "</span><span class="token punctuation">)</span> <span class="token operator">|</span> trim<span class="token punctuation">(</span><span class="token string">" caimengzhi "</span><span class="token punctuation">)</span> <span class="token operator">|</span> trim<span class="token punctuation">(</span><span class="token string">"cai mengzhi"</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------+--------------+----------------------+---------------------+</span>
<span class="token operator">|</span> cai          <span class="token operator">|</span> zhi          <span class="token operator">|</span> caimengzhi           <span class="token operator">|</span> cai mengzhi         <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">--------------+--------------+----------------------+---------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-9-replace"><a href="#2-9-replace" class="headerlink" title="2.9 replace"></a>2.9 replace</h3><p>替换函数 REPLACE(s，s1，s2) 使用字符串 s2 替换字符串 s 中所有的字符串 s1。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> replace<span class="token punctuation">(</span><span class="token string">'ILoveChina'</span><span class="token punctuation">,</span><span class="token string">'Love'</span><span class="token punctuation">,</span><span class="token string">'_LOVE_'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------------------+</span>
<span class="token operator">|</span> replace<span class="token punctuation">(</span><span class="token string">'ILoveChina'</span><span class="token punctuation">,</span><span class="token string">'Love'</span><span class="token punctuation">,</span><span class="token string">'_LOVE_'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------------------+</span>
<span class="token operator">|</span> I_LOVE_China                          <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-10-substring"><a href="#2-10-substring" class="headerlink" title="2.10 substring"></a>2.10 substring</h3><p>获取子串函数 SUBSTRING(s，n，len) 带有 len 参数的格式，从字符串 s 返回一个长度同 len 字符相同的子字符串，起始于位置 n。也可能对 n 使用一个负值。假若这样，则子字符串的位置起始于字符串结尾的第 n 个字符，即倒数第 n 个字符，而不是字符串的开头位置。</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> substring<span class="token punctuation">(</span><span class="token string">'caimengzhi'</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>substring<span class="token punctuation">(</span><span class="token string">"caimenghi"</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>substring<span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">7</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+----------------------------+------------------------------+</span>
<span class="token operator">|</span> substring<span class="token punctuation">(</span><span class="token string">'caimengzhi'</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> substring<span class="token punctuation">(</span><span class="token string">"caimenghi"</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span> substring<span class="token punctuation">(</span><span class="token string">"caimengzhi"</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">7</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+----------------------------+------------------------------+</span>
<span class="token operator">|</span> mengzhi                   <span class="token operator">|</span> meng                       <span class="token operator">|</span> meng                         <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">---------------------------+----------------------------+------------------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h3 id="2-11-reverse"><a href="#2-11-reverse" class="headerlink" title="2.11 reverse"></a>2.11 reverse</h3><p>字符串逆序函数 REVERSE(s) 可以将字符串 s 反转，返回的字符串的顺序和 s 字符串的顺序相反</p>
<pre class=" language-sql"><code class="language-sql">mysql<span class="token operator">></span> <span class="token keyword">select</span> reverse<span class="token punctuation">(</span><span class="token number">123456</span><span class="token punctuation">)</span><span class="token punctuation">,</span>reverse<span class="token punctuation">(</span><span class="token string">'caimengzhi'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------+-----------------------+</span>
<span class="token operator">|</span> reverse<span class="token punctuation">(</span><span class="token number">123456</span><span class="token punctuation">)</span> <span class="token operator">|</span> reverse<span class="token punctuation">(</span><span class="token string">'caimengzhi'</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------+-----------------------+</span>
<span class="token operator">|</span> <span class="token number">654321</span>          <span class="token operator">|</span> ihzgnemiac            <span class="token operator">|</span>
<span class="token operator">+</span><span class="token comment" spellcheck="true">-----------------+-----------------------+</span>
<span class="token number">1</span> <span class="token keyword">row</span> <span class="token operator">in</span> <span class="token keyword">set</span> <span class="token punctuation">(</span><span class="token number">0.00</span> sec<span class="token punctuation">)</span></code></pre>
<h2 id="3-MySQL-日期和时间函数"><a href="#3-MySQL-日期和时间函数" class="headerlink" title="3. MySQL 日期和时间函数"></a>3. MySQL 日期和时间函数</h2><table>
<thead>
<tr>
<th>函数名称</th>
<th>作 用</th>
</tr>
</thead>
<tbody><tr>
<td>CURDATE 和 CURRENT_DATE</td>
<td>两个函数作用相同，返回当前系统的日期值</td>
</tr>
<tr>
<td>CURTIME 和 CURRENT_TIME</td>
<td>两个函数作用相同，返回当前系统的时间值</td>
</tr>
<tr>
<td>NOW 和  SYSDATE</td>
<td>两个函数作用相同，返回当前系统的日期和时间值</td>
</tr>
<tr>
<td>UNIX_TIMESTAMP</td>
<td>获取UNIX时间戳函数，返回一个以 UNIX 时间戳为基础的无符号整数</td>
</tr>
<tr>
<td>FROM_UNIXTIME</td>
<td>将 UNIX 时间戳转换为时间格式，与UNIX_TIMESTAMP互为反函数</td>
</tr>
<tr>
<td>MONTH</td>
<td>获取指定日期中的月份</td>
</tr>
<tr>
<td>MONTHNAME</td>
<td>获取指定日期中的月份英文名称</td>
</tr>
<tr>
<td>DAYNAME</td>
<td>获取指定曰期对应的星期几的英文名称</td>
</tr>
<tr>
<td>DAYOFWEEK</td>
<td>获取指定日期对应的一周的索引位置值</td>
</tr>
<tr>
<td>WEEK</td>
<td>获取指定日期是一年中的第几周，返回值的范围是否为 0〜52 或 1〜53</td>
</tr>
<tr>
<td>DAYOFYEAR</td>
<td>获取指定曰期是一年中的第几天，返回值范围是1~366</td>
</tr>
<tr>
<td>DAYOFMONTH</td>
<td>获取指定日期是一个月中是第几天，返回值范围是1~31</td>
</tr>
<tr>
<td>YEAR</td>
<td>获取年份，返回值范围是 1970〜2069</td>
</tr>
<tr>
<td>TIME_TO_SEC</td>
<td>将时间参数转换为秒数</td>
</tr>
<tr>
<td>SEC_TO_TIME</td>
<td>将秒数转换为时间，与TIME_TO_SEC 互为反函数</td>
</tr>
<tr>
<td>DATE_ADD 和 ADDDATE</td>
<td>两个函数功能相同，都是向日期添加指定的时间间隔</td>
</tr>
<tr>
<td>DATE_SUB 和 SUBDATE</td>
<td>两个函数功能相同，都是向日期减去指定的时间间隔</td>
</tr>
<tr>
<td>ADDTIME</td>
<td>时间加法运算，在原始时间上添加指定的时间</td>
</tr>
<tr>
<td>SUBTIME</td>
<td>时间减法运算，在原始时间上减去指定的时间</td>
</tr>
<tr>
<td>DATEDIFF</td>
<td>获取两个日期之间间隔，返回参数 1 减去参数 2 的值</td>
</tr>
<tr>
<td>DATE_FORMAT</td>
<td>格式化指定的日期，根据参数返回指定格式的值</td>
</tr>
<tr>
<td>WEEKDAY</td>
<td>获取指定日期在一周内的对应的工作日索引</td>
</tr>
</tbody></table>
<h2 id="4-MySQL-聚合函数"><a href="#4-MySQL-聚合函数" class="headerlink" title="4. MySQL 聚合函数"></a>4. MySQL 聚合函数</h2><table>
<thead>
<tr>
<th>函数名称</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>MAX</td>
<td>查询指定列的最大值</td>
</tr>
<tr>
<td>MIN</td>
<td>查询指定列的最小值</td>
</tr>
<tr>
<td>COUNT</td>
<td>统计查询结果的行数</td>
</tr>
<tr>
<td>SUM</td>
<td>求和，返回指定列的总和</td>
</tr>
<tr>
<td>AVG</td>
<td>求平均值，返回指定列数据的平均值</td>
</tr>
</tbody></table>
<h2 id="5-MySQL-流程控制函数"><a href="#5-MySQL-流程控制函数" class="headerlink" title="5. MySQL 流程控制函数"></a>5. MySQL 流程控制函数</h2><table>
<thead>
<tr>
<th>函数名称</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>IF</td>
<td>判断，流程控制</td>
</tr>
<tr>
<td>IFNULL</td>
<td>判断是否为空</td>
</tr>
<tr>
<td>CASE</td>
<td>搜索语句</td>
</tr>
</tbody></table>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caimengzhi.gitee.io" rel="external nofollow noreferrer">夏天</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caimengzhi.gitee.io/2020/03/21/nosql/mysql-innerfunction/">https://caimengzhi.gitee.io/2020/03/21/nosql/mysql-innerfunction/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://caimengzhi.gitee.io" target="_blank">夏天</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">学习</span>
                                </a>
                            
                                <a href="/tags/SQL/">
                                    <span class="chip bg-color">SQL</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
    #love{
       color:red; 
    }
    #page_over{
       height: 38px;
       text-align:center;
       font-size: 20px;
       line-height: 38px;
       background-color: #8FDFDB; 
    }
</style>

<div id="reward">
    <div id="page_over">--------本文结束感谢您的阅读!---------</div>
    <h4><span id="love">❤</span></span>如果文章能够帮到您的话，不妨就支持一下小编呗!<span id="love">❤</span></h4>
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    

    

    

    
    <div class="livere-card card" data-aos="fade-up">
    <!-- 来必力City版安装代码 -->
    <div id="lv-container" class="card-content" data-id="city" data-uid="MTAyMC80OTUxNS8yNjAwNgs">
        <script type="text/javascript">
            (function (d, s) {
                let j, e = d.getElementsByTagName(s)[0];
                if (typeof LivereTower === 'function') {
                    return;
                }

                j = d.createElement(s);
                j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
                j.async = true;

                e.parentNode.insertBefore(j, e);
            })(document, 'script');
        </script>
        <noscript>为正常使用来必力评论功能请激活JavaScript。</noscript>
    </div>
    <!-- City版安装代码已完成 -->
</div>
    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/03/21/english/english2/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="单词">
                        
                        <span class="card-title">单词</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            名词
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-21
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/English/" class="post-category">
                                    English
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E5%8D%95%E8%AF%8D/">
                        <span class="chip bg-color">单词</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/03/21/cmz/cmz/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/6.jpg" class="responsive-img" alt="简历">
                        
                        <span class="card-title">简历</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            简历
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-03-21
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%AE%80%E5%8E%86/" class="post-category">
                                    简历
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E7%AE%80%E5%8E%86/">
                        <span class="chip bg-color">简历</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
    
    <div class="container row center-align" style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="https://caimengzhi.gitee.io" target="_blank">夏天</a>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">39.7k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
           
        
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2019";
                    var startMonth = "6";
                    var startDate = "28";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script> 
            <script type="text/javascript">  
                document.write('欢迎来自:' + returnCitySN["cname"]+'的朋友' + ",您的IP:" + returnCitySN["cip"] + ",浏览器版本:"+getBrowserInfo());
                function getBrowserInfo()
                {
                    var agent = navigator.userAgent.toLowerCase() ;
                    var regStr_ie = /msie [\d.]+;/gi ;
                    var regStr_ff = /firefox\/[\d.]+/gi
                    var regStr_chrome = /chrome\/[\d.]+/gi ;
                    var regStr_saf = /safari\/[\d.]+/gi ;
                    //IE
                    if(agent.indexOf("msie") > 0)
                    {
                        return agent.match(regStr_ie) ;
                    }
                    //firefox
                    if(agent.indexOf("firefox") > 0)
                    {
                        return agent.match(regStr_ff) ;
                    }
                    //Chrome
                    if(agent.indexOf("chrome") > 0)
                    {
                        return agent.match(regStr_chrome) ;
                    }
                    //Safari
                    if(agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0)
                    {
                        return agent.match(regStr_saf) ;
                    }
                }
            </script> 
        
            
            <span id="icp"><img src="/medias/icp.png" style="vertical-align: text-bottom;" />
                <a href="https://caimengzhi.gitee.io/books/" target="_blank">爱一直在线</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://caimengzhi.gitee.io/books/" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:610658552@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=QQ 联系我 610658552" class="tooltipped" target="_blank" data-tooltip="QQ联系我: QQ 联系我 610658552" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>





    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    
   
    

    
    
    <script>
        (function (i, s, o, g, r, a, m) {
            i["DaoVoiceObject"] = r;
            i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date();
            a = s.createElement(o), m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            a.charset = "utf-8";
            m.parentNode.insertBefore(a, m)
        })(window, document, "script", ('https:' == document.location.protocol ? 'https:' : 'http:') +
            "//widget.daovoice.io/widget/6984b559.js", "daovoice")
        daovoice('init', {
            app_id: "29275150"
        });
        daovoice('update');
    </script>
    

    
    <script type="text/javascript" color="0,0,255"
        pointColor="0,0,255" opacity='0.7'
        zIndex="-1" count="99"
        src="/libs/background/canvas-nest.js"></script>
    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    
    <!-- caimengzhi 
    <div id="weather-view-he"></div>
    -->
    
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>

</html>

<script type="text/javascript">
//只在桌面版网页启用特效
var windowWidth = $(window).width();
if (windowWidth > 768) {
    document.write('<script type="text/javascript" src="/js/sakura.js"><\/script>');
}
</script>


<!--<script type="text/javascript" src="/js/click_show_text.js"></script>-->
<script type="text/javascript" src="/js/FunnyTitle.js"></script>

<canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas> 
<script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
<!--<script type="text/javascript" src="/js/fireworks.js"></script>-->
<script type="text/javascript" src="/js/cursor.js"></script>

<!-- summer -->
<script type="text/javascript">
WIDGET = {FID: '5bDQrVS13z'}
</script>
<script type="text/javascript" src="https://apip.weatherdt.com/float/static/js/r.js?v=1111"></script>